package com.eascs.crm.nsEditDetail.service;

import com.alibaba.fastjson.JSON;
import com.eascs.admin.common.vo.ModelResult;
import com.eascs.crm.nsEditDetail.dao.CustOpLogDao;
import com.eascs.crm.nsEditDetail.entity.CustOpLogEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CustOpLogService {

	@Autowired
	CustOpLogDao custOpLogDao;

	public ModelResult<CustOpLogEntity> saveLog(CustOpLogEntity entity,Object updateObj) {
		ModelResult<CustOpLogEntity> modelResult =new ModelResult<>();
		entity.setOpContentDown(JSON.toJSONString(updateObj));
		entity.setClassname(updateObj.getClass().getName());
		boolean result = custOpLogDao.saveEntity(entity);
		if(!result){
			return modelResult.withError(null,"插入失败");
		}
		modelResult.setModel(entity);
		return modelResult;
	}
	
}
